package com.shaoshaohuo.app.ui;

import java.util.Calendar;
import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.framework.SharedPreferencesHelper;
import com.shaoshaohuo.app.view.TopbarView;
import com.shaoshaohuo.app.utils.StringHelper;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class WithDrawEndingActivity extends BaseActivity {

	private TopbarView mTopbarView;
	private TextView tv_card, tv_name, tv_money, tv_date;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_withdrawending);
		initView();
		setUpView();
		initData();
	}

	private void initView() {
		mTopbarView = (TopbarView) this.findViewById(R.id.topbar);
		tv_money = (TextView) findViewById(R.id.tv_money);
		tv_card = (TextView) findViewById(R.id.tv_card);
		tv_name = (TextView) findViewById(R.id.tv_name);
		tv_date = (TextView) findViewById(R.id.tv_date);
	}

	private void setUpView() {
		mTopbarView.setCenterText("提现详情");
		mTopbarView.setLeftView(true, true);
	}

	private void initData() {
		tv_money.setText(SharedPreferencesHelper.getString(SharedPreferencesHelper.Field.SHOW_BANK_MONEY, ""));
		tv_card.setText(SharedPreferencesHelper.getString(SharedPreferencesHelper.Field.SHOW_BANK_ACCOUNT, ""));
		tv_name.setText(SharedPreferencesHelper.getString(SharedPreferencesHelper.Field.SHOW_BANK_ACCOUNT_NAME, ""));

		Calendar calendar = Calendar.getInstance();
		int way = calendar.get(Calendar.DAY_OF_WEEK);
		int year = calendar.get(Calendar.YEAR);
		int month = calendar.get(Calendar.MONTH);
		int day = calendar.get(Calendar.DAY_OF_MONTH);
		int hour = calendar.get(Calendar.HOUR_OF_DAY);
		
		if(way==6&&hour>=12){//周五下午
			calendar.set(year, month, day+3, 23, 59, 0);
		}else if(way==7){//周六
			calendar.set(year, month, day+2, 23, 59, 0);
		}else if(way==1){//周日
			calendar.set(year, month, day+1, 23, 59, 0);
		}else{
			calendar.set(year, month, day+1, 23, 59, 0);
		}
		
		long timeInMillis = calendar.getTimeInMillis();
		String time = StringHelper.formatDateMinute(String.valueOf(timeInMillis));
		tv_date.setText("预计"+time+"前到账");
	}

	public void click(View v) {
		finish();
	}

}
